#include "Goal.h"
#include "CpuControlledVertibrateObject.h"
#include "Behavior.h"

Goal::Goal(Behavior * behavior, 
	bool (CpuControlledVertibrateObject::*CharacterIsGoalMet)(void),
	NavigationEdge * (CpuControlledVertibrateObject::*CharacterFindSuitableLocation)(void))
{
	this->behavior = behavior;
	this->CharacterIsGoalMet = CharacterIsGoalMet;	
	this->CharacterFindSuitableLocation = CharacterFindSuitableLocation;
}
Goal::~Goal()
{
	if(behavior)
	{
		delete(behavior);
		behavior = NULL;
	}	
}
bool Goal::IsGoalMet(CpuControlledVertibrateObject * character)
{
	if(character && this->CharacterIsGoalMet)
	{
		return (character->*CharacterIsGoalMet)();	
	}
	return true; //otherwise we'll keep trying to reach an impossible goal,
				 //and that's just sad.
}
NavigationEdge * Goal::FindSuitableLocation(CpuControlledVertibrateObject * character)
{
	if(character && this->CharacterFindSuitableLocation)
	{
		return (character->*CharacterFindSuitableLocation)();	
	}
	return NULL;
}
